package com.example.demo.mvvm.net;

import com.example.demo.mvvm.bean.ArticleBean;
import com.example.demo.mvvm.bean.BannerBean;
import com.example.demo.mvvm.bean.BaseDto;
import com.example.demo.mvvm.bean.HotKeyBean;
import com.example.demo.mvvm.bean.KnowBean;
import com.example.demo.mvvm.bean.ListDto;
import com.example.demo.mvvm.bean.UserBean;

import java.util.List;

/**
 * Created by 80711 on 2018/5/16.
 */

public class NetRequest {


    public static void getHomeArticle(int pageNum , BaseObserver<ListDto<ArticleBean>> listDtoBaseObserver){
        RetrofitClient.getInstance().getService().getHomeArticle(pageNum).compose(RxSchedulers.<BaseDto<ListDto<ArticleBean>>>compose()).subscribe(listDtoBaseObserver);
    }


    public static void getHomeBannerInfo(BaseObserver<List<BannerBean>> bannerObserver){
        RetrofitClient.getInstance().getService().getHomeBannerInfo().compose(RxSchedulers.<BaseDto<List<BannerBean>>>compose()).subscribe(bannerObserver);
    }

    public static void getKnowInfo(BaseObserver<List<KnowBean>> listBaseObserver){
        RetrofitClient.getInstance().getService().getKnowInfo().compose(RxSchedulers.<BaseDto<List<KnowBean>>>compose()).subscribe(listBaseObserver);
    }

    public static void getChildrenArticle(int pageNum , String cid , BaseObserver<ListDto<ArticleBean>> listDtoBaseObserver){
        RetrofitClient.getInstance().getService().getKownChildrenArticle(pageNum , cid).compose(RxSchedulers.<BaseDto<ListDto<ArticleBean>>>compose()).subscribe(listDtoBaseObserver);
    }

    public static void getHotKeyDatas(BaseObserver<List<HotKeyBean>> listBaseObserver){
        RetrofitClient.getInstance().getService().getHotKeyDatas().compose(RxSchedulers.<BaseDto<List<HotKeyBean>>>compose()).subscribe(listBaseObserver);
    }

    public static void getSearchDatas(int pageNum , String keyWord , BaseObserver<ListDto<ArticleBean>> listBaseObserver){
        RetrofitClient.getInstance().getService().getSearchDatas(pageNum , keyWord).compose(RxSchedulers.<BaseDto<ListDto<ArticleBean>>>compose()).subscribe(listBaseObserver);
    }

    public static void login(String name , String password , BaseObserver<UserBean> listBaseObserver){
        RetrofitClient.getInstance().getService().login(name , password).compose(RxSchedulers.<BaseDto<UserBean>>compose()).subscribe(listBaseObserver);
    }

    public static void register(String name , String password , BaseObserver<UserBean> listBaseObserver){
        RetrofitClient.getInstance().getService().register(name , password , password).compose(RxSchedulers.<BaseDto<UserBean>>compose()).subscribe(listBaseObserver);
    }

    public static void addCollect(int collectId , BaseObserver listBaseObserver){
        RetrofitClient.getInstance().getService().addcollect(collectId).compose(RxSchedulers.<BaseDto>compose()).subscribe(listBaseObserver);
    }

    public static void removeCollect(int collectId , int  originId,BaseObserver listBaseObserver){
        RetrofitClient.getInstance().getService().removeCollect(collectId , originId).compose(RxSchedulers.<BaseDto>compose()).subscribe(listBaseObserver);
    }

}
